package cn.usian.service.impl;

import cn.usian.feign.ProjectFeign;
import cn.usian.mapper.DailyMapper;
import cn.usian.pojo.Daily;
import cn.usian.service.DailyService;
import cn.usian.vo.DailyVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.stream.Collectors;

@Service
public class DailyServiceImpl extends ServiceImpl<DailyMapper, Daily> implements DailyService {
    @Autowired
    ProjectFeign projectFeign;
    @Override
    public Page<DailyVo> findPage(Integer pageNum, Integer pageSize) {
        Page<DailyVo> voPage = new Page<>(pageNum,pageSize);
        voPage=this.baseMapper.findPage(voPage);
        voPage.getRecords().stream().map(dailyVo -> {
            dailyVo.setPname(projectFeign.findProjectByName(dailyVo.getPid()).getName());
            return dailyVo;
        }).collect(Collectors.toList());
        return voPage;
    }
}
